home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectPlay / DXVBMessenger / modMsgShared.bas < prev   
BASIC Source File  |  2001-10-08  |  3KB  |  83 lines

  1. Attribute VB_Name = "modMsgShared"
  2. Option Explicit
  3. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  4. '
  5. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  6. '
  7. '  File:       modMsgShared.bas
  8. '
  9. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  10.  
  11. 'Constant encryption keys for both the server and client
  12. Public Const glClientSideEncryptionKey As Long = 169
  13. Public Const glServerSideEncryptionKey As Long = 131
  14.  
  15. 'Unique GUID for the app (used by DPlay)
  16. Public Const AppGuid = "{0AC3AAC4-5470-4cc0-ABBE-6EF0B614E52A}"
  17. 'Host and connect on this port
  18. Public Const glDefaultPort As Long = 9123
  19.  
  20. 'System Tray Declares/Constants/Types
  21. Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long
  22. Public Type NOTIFYICONDATA
  23.     cbSize As Long
  24.     hwnd As Long
  25.     uID As Long
  26.     uFlags As Long
  27.     uCallbackMessage As Long
  28.     hIcon As Long
  29.     sTip As String * 64
  30. End Type
  31. Public Const NIM_ADD = &H0
  32. Public Const NIM_MODIFY = &H1
  33. Public Const NIM_DELETE = &H2
  34. Public Const NIF_MESSAGE = &H1
  35. Public Const NIF_ICON = &H2
  36. Public Const NIF_TIP = &H4
  37. Public Const NIF_DOALL = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
  38. Public Const WM_MOUSEMOVE = &H200
  39. Public Const WM_LBUTTONDBLCLK = &H203
  40. Public Const WM_RBUTTONUP = &H205
  41. Public sysIcon As NOTIFYICONDATA
  42.  
  43. Public Enum vbMessengerMsgTypes
  44.     'Login messages
  45.     Msg_Login 'Login information
  46.     Msg_LoginSuccess 'Logged in successfully
  47.     Msg_CreateNewAccount 'A new account needs to be created
  48.     Msg_InvalidPassword 'The password for this account is invalid
  49.     Msg_InvalidUser 'This user doesn't exist
  50.     Msg_UserAlreadyExists 'This user already exists (only can be received after a CreateNewAcct msg)
  51.     'Friend Controls
  52.     Msg_AddFriend 'Add a friend to my list
  53.     Msg_FriendAdded 'User was added
  54.     Msg_FriendDoesNotExist 'Tried to add a friend that doesn't exist
  55.     Msg_BlockUserDoesNotExist 'Tried to block a user that doesn't exist
  56.     Msg_BlockFriend 'Block someone from contacting me
  57.     Msg_FriendBlocked 'User was blocked
  58.     Msg_DeleteFriend 'Delete this user from my list of friends
  59.     Msg_SendClientFriends 'The Server will send the client it's list of friends
  60.     'Messages
  61.     Msg_SendMessage 'Send a message to someone
  62.     Msg_UserBlocked 'Can't send a message to this person, they've blocked you
  63.     Msg_ReceiveMessage 'Received a message
  64.     Msg_UserUnavailable 'The user you are trying to send a message to is no longer logged on
  65.     'Friend Logon messages
  66.     Msg_FriendLogon 'A friend has just logged on
  67.     Msg_FriendLogoff 'A friend has just logged off
  68. End Enum
  69.  
  70. 'Here we will use a very basic encrytion scheme.  We will encrypt the password
  71. 'on the client side, before we send it over to the server, and then decrypt it
  72. 'on the server side, and encrypt it once more before checking it against the database
  73. Public Function EncodePassword(sOldStr As String, ByVal lEncryptKey) As String
  74.  
  75.     Dim lCount As Long, sNew As String
  76.     
  77.     'Do a simple replace on each character in the string
  78.     For lCount = 1 To Len(sOldStr)
  79.         sNew = sNew & Chr$(Asc(Mid$(sOldStr, lCount, 1)) Xor lEncryptKey)
  80.     Next
  81.     EncodePassword = sNew
  82. End Function
  83.